/*
 * Copyright (C) 2010-2011 Graz University of Technology, Austria. All Rights reserved. 
 *
 * Contact: Simone Kopeinik <simone.kopeinik@tugraz.at>
 * 	   Graz University of Technology, Knowledge Management Institute, Brückenkopfgasse 1/6, 8020 Graz 	
 * 	   <http://www.kmi.tugraz.at/>
 * 
 * This software is part of the TARGET platform developed by the
 * TARGET EC-funded project www.reachyourtarget.org
 *
 * This software is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * The GNU General Public License is available at <http://www.gnu.org/licenses/>.
 *
 */
package at.tugraz.kmi.css.cbkst2;

import java.io.Serializable;

import javax.annotation.Nonnull;


/**
 * Convenience Base Class for {@link CbKSTCompetence} and
 * {@link CbKSTPerformance} classes. Not really needed, but handy to have for
 * the default implementations.
 * 
 * @author Georg Öttl <georg.oettl@gmail.com>
 * 
 */
public abstract class CbKSTVertex extends ImmutableCbKSTVertex implements  Serializable {

	private static final long		serialVersionUID		= 1L;

	/**
	 * For BeanCopyProperty
	 */
	public final static String		PROPERTY_NAME			= "name";

	/**
	 * For BeanCopyProperty
	 */
	public final static String		PROPERTY_DESCRIPTION	= "description";

	/**
	 * General public constructor for a vertex...
	 */
	public CbKSTVertex() {
		this("Gen:" + incrementCounter());
	}

	/**
	 * @param id
	 *            A id for the vertex
	 */
	public CbKSTVertex(@Nonnull String id) {
		this.id = id;
		name = id;
	}

	/**
	 * s Change the ID of a Vertex. Use with care!
	 * 
	 * @param id
	 */
	public void setId(@Nonnull String id) {
		this.id = id;

	}

	/**
	 * Sets an arbitrary string name for this vertext. useful to easily
	 * "remember" the name despite the probably generic id.
	 * 
	 * @param name
	 */
	public void setName(@Nonnull String name) {
		String old = this.name;
		this.name = name;
		firePropertyChange(PROPERTY_NAME, old, name);
	}

	/**
	 * Any description that explains the meaning of this vertex.
	 * 
	 * @param description
	 */
	public void setDescription(@Nonnull String description) {
		String old = this.description;
		this.description = description;
		firePropertyChange(PROPERTY_DESCRIPTION, old, description);
	}

	@Override
	public String toString() {
		return String.format("%s", getId());
	}

}
